#ifndef SCRIPT_EDITOR_H
#define SCRIPT_EDITOR_H

#include "ieditor.h"

#include <QtGui/QTextEdit>

class ScriptEditor : public QTextEdit, public IEditor
{
    Q_OBJECT

public:
    ScriptEditor(QWidget *parent = 0);
    ~ScriptEditor();

    // IEditor
    void open(const QSharedPointer<IDocument>& document);
    void close(const QSharedPointer<IDocument>& document);

    QSharedPointer<IDocument> document() const;
    QWidget* widget() const;

    void registerFocusListener(QObject* object);
    void unregisterFocusListener(QObject* object);

    bool eventFilter(QObject *watched, QEvent *event);

private:
    void sendFocusEvent(bool focusIn = true) const;

protected:
    QList<QObject* > m_focusListeners;

    QSharedPointer<IDocument> m_document;
    QTextDocument* m_documentData;
};

#endif
